var MongoClient = require('mongodb').MongoClient;

export const config = {
  account:"root",
  psd:'root',
  host:'162.14.96.186',
  port:37019,
  dataBase:"shop",
  auth:"admin",
}
export const  Url = `mongodb://${config.account}:${config.psd}@${config.host}:${config.port}/${config.dataBase}?authSource=${config.auth}`;

export const client = new MongoClient(Url, { useNewUrlParser: true,useUnifiedTopology: true })

export const db = async()=>{
  const client = new MongoClient(Url, { useNewUrlParser: true,useUnifiedTopology: true })
  await client.connect();
  const database = client.db(config.dataBase);
  return database
}